# Python 2.6.4
# Project Euler, Problem 75
# Copyright 2010 Talha Zaman

def gcd(a, b):
    a, b = sorted([a, b])
    while a%b: a, b = b, a%b
    return b

def PPT():
    uv = 3
    while uv<=1000:
        for u in range(1,1+uv/2):
            v = uv - u
            if gcd(u, v)!=1: continue
            yield sorted([v**2-u**2, 2*u*v, v**2+u**2])
        uv += 2
from time import clock
start = clock()
perim = [0]*1000001
for t in PPT():
    p = sum(t)
    while p<=1000000:
        perim[p] += 1
        p += sum(t)
stop = clock()
print perim.count(1)
print stop-start
